package com.example.demo.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.example.demo.config.MyWebConfig;
import com.example.demo.entity.User;
import com.example.demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2018/3/18/018.
 */
@Controller
public class TestController extends BaseController {

    @Autowired
    private MyWebConfig myWebConfig;

    @Autowired
    private IUserService userService;


    @RequestMapping("/test")
    @ResponseBody
    public List<User> test(Model model) {
        String name = "李超";
//        User user = userService.selectUserByName(name);

        Page<User> page = userService.selectUserList(new Page<>(1, 2), 10);
        logger.info("新日志：" + page.toString());
        return page.getRecords();
    }

    @RequestMapping("/login")
    @ResponseBody
    public String login() {
        System.out.println(myWebConfig.getName());
//        User user = new User("李超",18,2);


        User user1 = userService.selectUserByName("李超");
        user1.setAge(25);
        userService.updateById(user1);

        return "index";
    }

}

